package cn.cau.service.impl;

import cn.cau.dao.BasicEnumDao;
import cn.cau.entity.BasicEnum;
import cn.cau.entity.BasicEnumSum;
import cn.cau.service.BasicEnumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BasicEnumServiceImpl implements BasicEnumService {
    @Autowired
    private BasicEnumDao basicEnumDao;
    @Override
    public int insertBasicEnum(BasicEnum basicEnum) {
        return basicEnumDao.insertBasicEnum(basicEnum);
    }

    @Override
    public List<BasicEnum> findBasicEnumByCodeRuleId(int codeRuleId) {
        return basicEnumDao.findBasicEnumByCodeRuleId(codeRuleId);
    }
    @Override
    public List<List<BasicEnum>>findBasicEnumSByCodeRuleId(int codeRuleId,int count){
        List<List<BasicEnum>> a=null;
        for (int i = 0; i <count; i++) {
            List<BasicEnum> b=null;

            int num=basicEnumDao.findBasicEnumNumByCodeCodeId(codeRuleId,i+1);
            for (int j = 0; j <num; j++) {
                BasicEnum c;
                c=basicEnumDao.findBasicEnumByCodeRuleIdAndCount(codeRuleId,i+1,j+1);
                b.add(c);
            }
            a.add(b);
        }
        return a;
    }

    @Override
    public List<BasicEnum> findBasicEnumByCodeIdAndPos(int codeId, int pos) {
        return basicEnumDao.findBasicEnumByCodeIdAndPos(codeId,pos);
    }

    @Override
    public List<BasicEnumSum> findBasicEnumSumByCodeRuleId(int codeRuleId) {
        return basicEnumDao.findBasicEnumSumByCodeRuleId(codeRuleId);
    }
}
